package top.lemna.account.domain;

import org.mapstruct.BeanMapping;
import org.mapstruct.Mapper;
import org.mapstruct.MappingTarget;
import org.mapstruct.NullValueCheckStrategy;
import org.mapstruct.NullValuePropertyMappingStrategy;
import org.mapstruct.factory.Mappers;

import top.lemna.account.persistence.AccountPo;

@Mapper
public interface AccountMapper {

    AccountMapper INSTANCE = Mappers.getMapper(AccountMapper.class);

    Account toDomain(AccountPo doctor);

    void toPo(Account account, @MappingTarget AccountPo accountPo);

    @BeanMapping(//
            nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE, //
            nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS//
    )
    void update(@MappingTarget AccountPo accountPo, Account account);
}
